{include file="admin/header.tpl" title="header" }
<script>
{literal}
 
function showBannerType(str){
         if(str=='image'){
		  		document.getElementById('image').style.display ='';
		  		document.getElementById('txt_field').style.display ='none';
	     }else{
		  		document.getElementById('txt_field').style.display ='';
		  		document.getElementById('image').style.display ='none';
	     }
			 
}//end showDive function 

function pickPositionSizes(position){	
   $('#divBannerSizes').html('<img src="../templates/admin/images/loading.gif">');	
   $.post(
     baseurl+"/admin/banners.php", 
     { action: "load_positionsize", position_id : position }, 
     function(data){
      $('#divBannerSizes').html(data);      
     } 
    );
}
function frmValidation()
{ 
		      var banner_name = jQuery.trim(document.getElementById('banner_name').value);
			  var banner_category = jQuery.trim(document.getElementById('banner_category').value);
			  var banner_type = jQuery.trim(document.getElementById('banner_type').value);
			  var banner_code = jQuery.trim(document.getElementById('banner_code').value);
			  var banner_name = jQuery.trim(document.getElementById('banner_name').value);
			  var banner_image = document.getElementById('banner_image').value;
			  var banner_position = document.getElementById('banner_position').value;
			 // var banner_size = document.getElementById('banner_size').value;
			  var banner_set_frequency = document.getElementById('banner_set_frequency').value;
			  var banner_image = document.getElementById('banner_image').value;
			  //alert(banner_image);return false;
			  	
				 if(banner_name==''){
				     alert('Please enter banner name.');
					 document.getElementById('banner_name').focus();
					 return false;
				 }	
				 if(banner_name!='' && (!ch_validAlphaNumericName(banner_name))){
				     alert('Invalid characters, please enter valid characters in ground name');
					 document.getElementById('banner_name').focus();
					 return false;
				 }
				 if(banner_type==''){
				     alert('Please select banner type.');
					 document.getElementById('banner_code').focus();
					 return false;
				 }
				 if( (banner_type=='code' || banner_type=='flash' )&&  banner_code==''){
				     alert('Please enter banner code.');
					 document.getElementById('banner_code').focus();
					 return false;
				 }	
				 if((banner_type=='image') &&  banner_image==''){
				     alert('Please select image to upload.');
					 //document.getElementById('banner_category').focus();
					 return false;
				 }	
				 if((banner_position=='')){
				     alert('Please select banner position.');
					 document.getElementById('banner_position').focus();
					 return false;
				 }	
				 	
				 if((banner_set_frequency=='')){
				     alert('Please set banner frequency.');
					 document.getElementById('banner_set_frequency').focus();
					 return false;
				 }
				 if(banner_set_frequency!='' && (!ch_isInteger(banner_set_frequency))){
				     alert('Please enter only integer value.');
					 document.getElementById('banner_set_frequency').focus();
					 return false;
				 }
				 		
			  
		   }
	{/literal}

</script>

		  {* $post|var_dump *}
          
          {if isset($post.banner_id) }
          	{assign var='action' value='update'}
            {assign var='page_heading' value='Edit'}
          {else} 
          	{assign var='action' value='add'}
            {assign var='page_heading' value='Add'}
          {/if}

    <div id="content">
    
    
    {php} echo display_msg(); {/php}
    {if isset($post.banner_id) }
      	<h2>Edit Banner</h2>
           <div class="lstable">
           <form name="bannerfrm"  id="bannerfrm" method="post" enctype="multipart/form-data"  onsubmit="return frmValidation();">
           	<input type="hidden" name="action" id="action" value="edit">
            <input type="hidden" name="old_banner_image" id="old_banner_image" value="{$post.banner_image}">
            <input type="hidden" name="banner_id" value="{$post.banner_id}" />
          
        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
             
          	<tr>
                <td width="20%" align="left" valign="middle"><strong>Banner Name : <span class="mandatory">*</span></strong></td>
                <td width="20%" align="left" valign="middle"><input type="text" name="banner_name" id="banner_name" value="{$post.banner_name|stripslashes}" maxlength="255" /></td>
                <td width="55%">&nbsp;  </td>
           </tr>
            
            
            <tr >
                <td width="20%" align="left" valign="top"><strong>Banner Image :<span class="mandatory">*</span></strong></td>
                <td width="40%" align="left" valign="middle">
                   <input type="file" name="banner_image" id="banner_image" maxlength="255" value="{$post.banner_image}" ><br /><img src="../images/banners/{$post.banner_image}" height="100">
                   <input type="hidden" name="old_banner_image" id="old_banner_image" value="{$post.banner_image}">
                </td>
                <td width="35%">&nbsp;  </td>
           </tr>
           
            
            
          <tr>
                <td width="20%" align="left" valign="middle"><strong>Banner Link :</strong></td>
                <td width="20%" align="left" valign="middle"><input type="text" name="banner_link" id="banner_link" value="{$post.banner_link|stripslashes}"  maxlength="255" /></td>
                <td width="55%">&nbsp;  </td>
           </tr>
          
           
          <tr>
           <td>&nbsp;</td>
            <td  colspan="2" align="left"><input name="submit"  class="btncss" type="submit" value="Save" />&nbsp;<input class="btncss" type="button" onclick="if(! confirm(global_canel_comfirm_msg) ) return true;  location.href='{$baseurl}/admin/banners.php?&pg={$pg}&ipp={$ipp}&new_page_limit={$new_page_limit}&banner_name={$banner_name}&banner_name={$banner_name}'" value="Cancel" /></td>
            
          </tr>
          </table>
          </form>
      </div>
    {else}
     <h2>Add Banner</h2>
     <div class="lstable">
           <form name="bannerfrm"  id="bannerfrm" method="post" enctype="multipart/form-data" onsubmit="return true; //frmValidation();">
           	<input type="hidden" name="action" id="action" value="add">
           
        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
             
          	<tr>
                <td width="20%" align="left" valign="middle"><strong>Banner Name : <span class="mandatory">*</span></strong></td>
                <td width="20%" align="left" valign="middle"><input type="text" name="banner_name" id="banner_name" value="{$post.banner_name|stripslashes}" maxlength="255"/></td>
                <td width="55%">&nbsp;  </td>
           </tr>
            
            
            <tr >
                <td width="20%" align="left" valign="top"><strong>Banner Image :<span class="mandatory">*</span></strong></td>
                <td width="40%" align="left" valign="middle">
                   <input type="file" name="banner_image" id="banner_image" maxlength="255" >
                   <input type="hidden" name="old_banner_image" id="old_banner_image" value="{$post.banner_image}">
                </td>
                <td width="35%">&nbsp;  </td>
           </tr>
            
            
          
         
          
          <tr>
                <td width="20%" align="left" valign="middle"><strong>Banner Link :</strong></td>
                <td width="20%" align="left" valign="middle"><input type="text" name="banner_link" id="banner_link" value="{$post.banner_link|stripslashes}" maxlength="255" /></td>
                <td width="55%">&nbsp;  </td>
           </tr>
          
          <tr>
           <td>&nbsp;</td>
            <td  colspan="2" align="left"><input name="submit"  class="btncss" type="submit" value="Save" />&nbsp;<input class="btncss" type="button" onclick="if(! confirm(global_canel_comfirm_msg) ) return true;  location.href='{$baseurl}/admin/banners.php'" value="Cancel" /></td>
            
          </tr>
          </table>
          </form>
      </div>
     {/if}
      
    </div>

   
 {include file="admin/footer.tpl" title="footer"}   